home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
comm
/
term
/
vltj5867.lha
/
VLT
/
rexx
/
Intercept.vlt
< prev
next >
Wrap
Text File
|
1994-03-27
|
1KB
|
55 lines
/** Intercept.vlt
*
* Example program to intercept keystrokes.
* Changes lower case b's into upper case C's, until you type a lower case a.
*
**/
/*
* Add libraries if necessary
*/
if show("l", "rexxarplib.library") = 0 then do
check = addlib('rexxsupport.library', 0, -30, 0)
check = addlib('rexxarplib.library', 0, -30, 0)
end
/*
* Open a port
*/
mp = openport(INTERCEPTPORT)
"message (Now type some lower case b's and other stuff.*NType a lower case a to get out.)"
/*
* Tell VLT to send us stuff
*/
"wedge keystrokes INTERCEPTPORT"
/*
* Loop until quitflag is 1, waiting for packets
*/
do forever
if quitflag = 1 then leave
t = waitpkt(INTERCEPTPORT)
/*
* We got a number of packets. Loop over all of them.
*/
do ff = 1
p = getpkt(INTERCEPTPORT)
if c2d(p) = 0 then leave ff
line = getarg(p)
/*
* Got a line. It is of the form: KEYSTROKE code qualifier iaddress character
* parse it out.
*/
parse var line command code qual iaddr char .
/*
* If we got an "a", quit. If a "b", say that we'll handle this one
* ourselves by replying a 0 error return and replace it with a capital C!
* Otherwise return a 1.
*/
if char = 'a' then quitflag = 1
if char = 'b' then do
t = reply(p, 0)
if (char = 'b') then "send (C); emit (C);"
end
else t = reply(p, 1)
end
end